<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/12/29
 * Time: 14:55
 */
include_once "./UploadClass.php";
$path = pathinfo(__FILE__)['dirname'];

if ($_FILES['file']['error'] == 0) {
    //$caseName = trim($_POST['caseName']);//获取参数
    $file_path =   $path.'/upload/';//设置文件路径
    $blob_num = $_POST['chunk'];//当前片数
    $total_num = $_POST['chunks'];//总片数
    $file_name = $_POST['name'];//文件名称
    $temp_name = $_FILES['file']['tmp_name'];//零时文件名称
    $uploadClass = new UploadClass($file_path, $blob_num, $total_num, $file_name, $temp_name);//实例化upload类，并传入相关参数
    $data = $uploadClass->apiReturn();
    return json_encode($data);
} else {
    $data['code'] = 0;
    $data['msg'] = 'error code:' . $_FILES['file']['error'];
    $data['file_path'] = '';
    return json_encode($data);
}